import Charts // !
import SwiftUI

struct ChartWithData : View {
    @State var scores: Array<Double> = [
        90.0, 86.0, 70.5, 92, 88, 91, 60, 100, 70, 60, 72, 87
    ]
    
    var body: some View {
        VStack {
            Text("Basic bar chart")
                .font(.largeTitle)
            
            // ForEach
            Chart(scores, id: \.self) {
                BarMark(
                    x: PlottableValue.value("Score", "\($0)"),
                    y: PlottableValue.value("Subject", $0)
                )
            }
            
            Chart(scores, id: \.self) {
                BarMark(
                    x: PlottableValue.value("Subject", $0),
                    y: PlottableValue.value("Score", "\($0)")
                )
            }
        }
    }
}
